package log4j;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.MDC;
import org.apache.log4j.PatternLayout;

import static log4j.Log4JUtils.newConsoleAppender;
import static log4j.Log4JUtils.newPatternLayout;

public class MDCJTest {
    private final static Logger logger;
    static {
        logger = Logger.getLogger("a.b.c");
        ConsoleAppender appender = newConsoleAppender();
        appender.setLayout(newPatternLayout("%-5p %d{HH:mm:ss,SSS} %C %M: %m"));
        logger.addAppender(appender);
    }

    public static void main(String[] args) {
        MDC.put("user", "Mike");
        test();
    }
    
    public static void test() {
        logger.error("Some error");
    }
}
